/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package desarrollosoft.ghce.dao.implementaciones;

import desarrollosoft.ghce.dao.interfaces.IPlantillaLaboratorioDAO;
import desarrollosoft.ghce.entidades.PlantillaEstudioLaboratorio;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author ariel
 */
@Repository("plantillaLaboratorioDAO")
public class PlantillaLaboratorioDAO implements IPlantillaLaboratorioDAO {

    @PersistenceContext
    private EntityManager entityManager;
    
    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void crearPlantilla(PlantillaEstudioLaboratorio plantillaEstudioLaboratorio) {
        entityManager.persist(plantillaEstudioLaboratorio);
    }

    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void modificarPlantilla(PlantillaEstudioLaboratorio plantillaEstudioLaboratorio) {
        entityManager.merge(plantillaEstudioLaboratorio);
    }

    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void eliminar(PlantillaEstudioLaboratorio plantillaEstudioLaboratorio) {
        entityManager.remove( entityManager.merge(plantillaEstudioLaboratorio) );
    }
    
}
